/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package cageballserver;

import cageballcommon.enummerations.TeamEnum;
import cageballcommon.exceptions.CageballMatchException;

/**
 *
 * @author kanonas
 */
public class Game {
    private CageballClient team1;
    private CageballClient team2;
    private TeamEnum winner;
    private int team1Score;
    private int team2Score;

    public Game(CageballClient team1, CageballClient team2) {
        this.team1 = team1;
        this.team2 = team2;
    }

    public CageballClient getTeam1() {
        return team1;
    }

    public CageballClient getTeam2() {
        return team2;
    }

    public TeamEnum getWinner() {
        return winner;
    }

    public void setWinner(TeamEnum winner) {
        this.winner = winner;
    }

    public int getTeam1Score() {
        return team1Score;
    }

    public void setTeam1Score(int team1Score) {
        this.team1Score = team1Score;
    }

    public int getTeam2Score() {
        return team2Score;
    }

    public void setTeam2Score(int team2Score) {
        this.team2Score = team2Score;
    }

    public int getMyScore(TeamEnum team) throws CageballMatchException{
        if(team == TeamEnum.myTeam){
            return team1Score;
        } else if(team == TeamEnum.otherTeam){
            return team2Score;
        } else{
            throw new CageballMatchException("Invalid team");
        }
    }

    public int getOtherScore(TeamEnum team) throws CageballMatchException{
        if(team == TeamEnum.myTeam){
            return team2Score;
        } else if(team == TeamEnum.otherTeam){
            return team1Score;
        } else{
            throw new CageballMatchException("Invalid team");
        }
    }
}
